#include "StdAfx.h"
#include "DD_PLCCtrl.h"
#include "xhPLCCtrl.h"


DD_PLCCtrl::DD_PLCCtrl(void)
{
	m_pxhPLCCtrl = NULL;
}

DD_PLCCtrl::~DD_PLCCtrl(void)
{
	MySafeDelete(m_pxhPLCCtrl);
}

#define DKQ_SECT {if( NULL== m_pxhPLCCtrl ) return -1;}

int DD_PLCCtrl::Initialize()
{
	if( NULL == m_pxhPLCCtrl )
	{
		m_pxhPLCCtrl = new xhPLCCtrl;
	}

	DKQ_SECT;
	return m_pxhPLCCtrl->Initialize();
}

int DD_PLCCtrl::UnInitialize()
{
	DKQ_SECT;
	return m_pxhPLCCtrl->UnInitialize();
}
//parent hwnd
int DD_PLCCtrl::SetHwnd(HWND hWnd)
{
	DKQ_SECT;
	return m_pxhPLCCtrl->SetHwnd(hWnd);
}
int DD_PLCCtrl::RegMsgCallBack(void *pfun, DWORD dwContext, void *pContext)
{
	DKQ_SECT;
	return m_pxhPLCCtrl->RegMsgCallBack(pfun,dwContext,pContext);
}



int DD_PLCCtrl::GetPlugList(zkPlugDescs **ppDescs)
{
	DKQ_SECT;
	return m_pxhPLCCtrl->GetPlugList(ppDescs);
}

int DD_PLCCtrl::SelectPlug(char *pDescName)
{
	DKQ_SECT;
	return m_pxhPLCCtrl->SelectPlug(pDescName);
}

int DD_PLCCtrl::OpParam(void *pVoid)
{
	DKQ_SECT;
	return m_pxhPLCCtrl->OpParam(pVoid);
}





int DD_PLCCtrl::SetComCfg(zkComCfg *pCfg)
{
	DKQ_SECT;
	return m_pxhPLCCtrl->SetComCfg(pCfg);
}
int DD_PLCCtrl::CheckConnect(int &nStatus)
{
	DKQ_SECT;
	return m_pxhPLCCtrl->CheckConnect(nStatus);
}

int DD_PLCCtrl::SetConfig(DWORD dwCommand, void* pInBuf,  DWORD dwInBufSize)
{
	DKQ_SECT;
	return m_pxhPLCCtrl->SetConfig(dwCommand,pInBuf,dwInBufSize);
}
int DD_PLCCtrl::GetConfig(DWORD dwCommand, void* pOutBuf, DWORD dwOutBufSize,DWORD *pdwBytesReturned)
{
	DKQ_SECT;
	return m_pxhPLCCtrl->GetConfig(dwCommand,pOutBuf,dwOutBufSize,pdwBytesReturned);
}

